package com.testMgmt.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

@Component
public class TestService {

    @Async
    public void asyncMethodReturnVoid() throws InterruptedException {
        Thread.sleep(1000);
    }

    @Async
    public Future<String> asyncMethodReturnString() {
        try {
            Thread.sleep(3000);

            return new AsyncResult<>("result");
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            e.printStackTrace();
        }
        return null;
    }
}
